package com.millstein.vod.controller;

import com.millstein.commonutils.Result;
import com.millstein.vod.service.VodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RequestMapping("/eduvod/vod")
@CrossOrigin
@RestController
public class VodController {

    @Autowired
    private VodService vodService;

    /**
     * 上传视频
     * @param file
     * @return
     */
    @PostMapping
    public Result uploadAliyunVideo(MultipartFile file) {
        String videoId = vodService.upload(file);
        return Result.ok().data("videoId", videoId);
    }

    /**
     * 删除上传到阿里云上的视频
     * @param id
     * @return
     */
    @DeleteMapping("{id}")
    public Result removeAliyunVideo(@PathVariable("id") String id) {
        vodService.remove(id);
        return Result.ok();
    }
}
